package com.atiguigu.springcloud.fallback;

import com.atguigu.springcloud.entity.CommonResult;
import com.atiguigu.springcloud.clients.PaymentClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author lizhilong
 * @create 2020/5/3 22:43
 * @desc
 */
@Component
@Slf4j
public class PaymentClientFallBack implements FallbackFactory<PaymentClient>{
    @Override
    public PaymentClient create(Throwable throwable) {
        return new PaymentClient() {
            @Override
            public CommonResult<String> get(Integer id) {
                return CommonResult.failure("支付服务繁忙，请稍后重试");
            }

            @Override
            public CommonResult<String> getTimeout(Integer id) {
                return CommonResult.failure("支付服务异常，请稍后重试");
            }

            @Override
            public CommonResult<String> breakTest(Integer id) {
                return CommonResult.failure("支付服务异常，请稍后重试");
            }
        };
    }
}
